<template>
  <view class="container">
    <!-- 政策内容 -->
    <view
      class="container_box"
      v-for="(item, index) in agentPolicyCostInfo"
      :key="index"
    >
      <view class="container__title u-border-bottom u-font-15">
        {{ item.activityName }}
      </view>
      <view class="flex list-item">
        <view class="flex-1"> 税点 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.taxPoint"
            placeholder=""
            disabled
          ></u-input>
          <text> % </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> 首次激活返现 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.activeRecash"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> 重复激活返现 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.repeatActiveRecash"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> 达标返现1 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.standardRecash1"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> 达标返现2 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.standardRecash2"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> 达标返现3 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.standardRecash3"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> sim卡返现1 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.flowRecash"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> sim卡返现2 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.flowRecash2"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
      <view class="flex list-item">
        <view class="flex-1"> sim卡返现3 </view>
        <view class="config_content">
          <u-input
            class="config_input"
            :border="border"
            v-model="item.flowRecash3"
            placeholder=""
            :disabled="isDisabled"
          ></u-input>
          <text> 元 </text>
        </view>
      </view>
    </view>
    <!-- 操作按钮 -->
    <view class="handle">
      <u-button @click="handleAddEdit" class="anniu" type="warning">
        提交修改
      </u-button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      agentPolicyCostInfo: [],
      border: true, //input边框
      isDisabled: false, //input框禁用
      agentNo: '', //代理商编号
    };
  },
  // onLoad自带一个参数
  onLoad(options) {
    console.log('options----->151', options);
    // 获取代理商编号
    this.agentNo = options.agentNo;
    // 赋值给agentPolicyCostInfo
    this.agentPolicyCostInfo = JSON.parse(options.agentPolicyCostInfo);
    console.log('this.agentPolicyCostInfo----->156', this.agentPolicyCostInfo);
  },
  methods: {
    // 提交修改返现事件
    async handleAddEdit() {
      // 打印修改返现配置数据;
      console.log('handleAddEdit----->162', this.agentPolicyCostInfo);
      // 修改返现配置数据接口
      const result = await this.$zx.common_api.editUpdateAgentCashBack(
        this.agentNo,
        { agentActivityInfoDtoList: this.agentPolicyCostInfo }
      );
      console.log('editUpdateAgentCashBack----->168', result);
      // 修改成功后提示
      uni.showToast({
        title: '修改成功',
        duration: 1000,
      });
      // 延迟1秒跳转回返现配置页面
      setTimeout(() => {
        this.$u.route({
          url: 'pages/main/agent/agentAddReappearanceAllocationMoney',
          params: {
            agentNo: this.agentNo, // 传递代理商编号
          },
        });
      }, 1000);
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  .container_box {
    background-color: white;
    margin-top: 30rpx;
    font-size: 28rpx;
  }
  .container__title {
    font-size: 28rpx;
    font-weight: bold;
    padding: 20rpx 20rpx;
  }
}
.bg {
  background-color: #f6f6f6;
  padding: 10rpx 20rpx;
  border-radius: 10rpx;
}
// 内容样式
::v-deep .list-item {
  align-items: center;
  padding: 10rpx 24rpx;
  .config_content {
    display: flex;
    align-items: center;
    .config_input {
      width: 100rpx;
      height: 60rpx;
      display: flex;
      align-items: center;
      background: #f6f6f6;
      border: 0rpx solid #dcdfe6;
      .u-input__input {
        text-align: center;
        font-size: 28rpx;
      }
    }
    text {
      margin-left: 10rpx;
    }
  }
}
// 按钮
::v-deep .handle {
  padding: 40rpx 0rpx;
  display: flex;
  left: 50%;
  position: fixed;
  bottom: 40rpx;
  transform: translateX(-50%);
  .custom {
    color: white;
    background: #9d60ff;
    margin-right: 60rpx;
  }
  .anniu {
    padding: 44rpx 80rpx;
  }
}
</style>
